# 20130606
# VMWare View 5.2
# This script creates a role for VMWare View Manager to operate in vCenter.
#
# Refer to the documentation
# # http://pubs.vmware.com/view-52/index.jsp?topic=%2Fcom.vmware.view.installation.doc%2FGUID-A878F876-B359-42FC-9124-A1E34BFB3319.html&resultof=%22%41%63%74%22%20%22%61%63%74%22%20%22%76%63%65%6e%74%65%72%22%20%22%73%65%72%76%65%72%22%20

# Include any helper functions
. ".\include\*.ps1"

# Include any predefined variables
. ".\configuration.ps1"

# Name for our role
$myRole = "ViewManagerRole"

# Remove the role before trying to create it
removeRole($myRole)

# Create our role
new-virole -Name $myRole

# Privileges needed for the View Manager Role
$myGuestPrivileges = @("Create Folder", "Delete Folder", "Add or remove device", "Advanced", "Modify device settings", "Power Off", "Power On", "Reset", "Suspend", "Create New", (get-viprivilege -Id VirtualMachine.Inventory.Delete), "Customize", "Deploy template", "Read customization specifications", "Assign virtual machine to resource pool", "Act as vCenter Server")

# Needed for View Storage Accelerator
$myStoragePrivileges = @("Advanced settings")

# Set basic privs
set-virole -Role $myRole -AddPrivilege $myGuestPrivileges

# Set privs needed for storage accelerator
if ($boolStorageAccelerator) {
		set-virole -Role $myRole -AddPrivilege $myStoragePrivileges
}